﻿using System;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Text;

namespace SHKF.B2C.MeiTuanPeiSong.Network
{
    public class SHA1Util
    {
        public static string Sha1(String s)
        {
            char[] hexDigits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
            byte[] btInput = Encoding.UTF8.GetBytes(s);

            HashAlgorithm iSha = new SHA1CryptoServiceProvider();
            byte[] strRes = iSha.ComputeHash(btInput);
            var enText = new StringBuilder();
            foreach (byte iByte in strRes)
            {
                enText.AppendFormat("{0:x2}", iByte);
            }
            return enText.ToString();
        }
    }
}
